<template>
  <div class="content">
    <div class="main">
      <h1 style="text-align: center; color: antiquewhite; margin-bottom: 30px;">后台管理系统</h1>
      <el-form :model="form" label-width="auto" class="demo-ruleForm" label-position="left">
        <el-form-item label="用户名">
          <el-input v-model="form.name" />
        </el-form-item>
        <el-form-item label="密码">
          <el-input v-model="form.password" />
        </el-form-item>
        <el-form-item label="验证码">
          <div class="ds">
            <el-input v-model="form.imageCode" />
            <el-image @click="getImageCode" style="width: 100px; height: 30px; margin-left: 10px;" :src="url" />
          </div>
        </el-form-item>
        <div class="ds cc">
          <el-button type="primary">登录</el-button>
        </div>
      </el-form>
    </div>
  </div>
</template>
<script  setup>
import { reactive, ref, onMounted } from 'vue'
import { getCaptcha } from '@/api/login'
let key = ref('')
let url = ref('')
onMounted(() => {
  getImageCode()
})
let getImageCode = () => {
  key.value = new Date().getTime().toString()
  getCaptcha({ key: key.value }).then(res => {
    let blob = new Blob([res.data],{type:"application/vnd.ms-excel"})
    let imgUrl = URL.createObjectURL(blob)
    url.value = imgUrl
    console.log(imgUrl,blob,url.value)
  })

}
let form = reactive({
  name: '',
  password: '',
  imageCode: ''
})
</script>
<style scoped>
.content {
  width: 100%;
  height: 100%;
  background-color: blanchedalmond;
  display: flex;
  justify-content: center;
  align-items: center;
}

.main {
  width: 400px;
  height: 360px;
  background: rgba(78, 118, 163, .2);
  padding: 20px;
  min-width: 400px;
  box-sizing: border-box;
}
</style>